<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <style>
       #jisuan {
            text-align: center;
            border: 1px solid;
            width: 300px;
            border-radius: 10px;
            background-color: aqua;
            margin: 20px auto;
            background-image: url(../bisai__lianxi/hu-ying\(1\).jpg);
        }

        #t {
            border: 1px solid ;
            width: 260px;
            border-radius: 10px;
            margin-top: 10px;
            margin-bottom: 10px;
            font-size: 20px;
        }

        .num {
            border-radius: 15px;
            width: 55px;
            height: 30px;
            margin: 2px;
            font-size: 20px;
        }

        #equ {
            width: 260px;
            font-size: 30px;
            margin-bottom: 10px;
        }
    </style>
    <title>计算器</title>
</head>
<body>
    <div id="jisuan">

        <input type="text" name="t" id="t" value="" /><br />
        <input type="button" name="" value="1" class="num" onclick="calCulate(this.value)" />
        <input type="button" name="" value="2" class="num" onclick="calCulate(this.value)" />
        <input type="button" name="" value="3" class="num" onclick="calCulate(this.value)" />
        <input type="button" name="" value="*" class="num" onclick="calCulate(this.value)" /><br />
        <input type="button" name="" value="4" class="num" onclick="calCulate(this.value)" />
        <input type="button" name="" value="5" class="num" onclick="calCulate(this.value)" />
        <input type="button" name="" value="6" class="num" onclick="calCulate(this.value)" />
        <input type="button" name="" value="+" class="num" onclick="calCulate(this.value)" /><br/>
        <input type="button" name="" value="7" class="num" onclick="calCulate(this.value)" />
        <input type="button" name="" value="8" class="num" onclick="calCulate(this.value)" />
        <input type="button" name="" value="9" class="num" onclick="calCulate(this.value)" />
        <input type="button" name="" value="-" class="num" onclick="calCulate(this.value)" /><br/>
        <input type="button" name="" value="C" class="num" onclick="calCulate(this.value)" />
        <input type="button" name="" value="0" class="num" onclick="calCulate(this.value)" />
        <input type="button" name="" value="." class="num" onclick="calCulate(this.value)" />
        <input type="button" name="" value="/" class="num" onclick="calCulate(this.value)" /><br />
        <input type="button" name="" id="equ" class="num" value="=" onclick="calCulate(this.value)" />
    </div>
    <script>

        function calCulate(val) {

            console.log("===>", val);

            var num = document.getElementById("t");
            switch (val) {
                case "=":
                    num.value = eval(num.value);

                    break;

                case "C":
                    num.value = "";
                    break;

                default:
                    num.value = num.value + val;
                    break;
            }


        }
    </script>
</body>
</html>